﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Media.Animation;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Media3D;
using System.Data;
using System.Reflection;
using System.Collections;
using System.Globalization;
using CrazyWorship1.PropertyHandler;
using System.Windows.Media;
namespace CrazyWorship1.Transitions
{
    public class FadeIn : BaseTransitionIn
    {
        DoubleAnimation fade;
        public override void SetupTransition()
        {
            fade=new DoubleAnimation();
            fade.To=1;
            fade.Duration=new Duration(new TimeSpan(0,0,0));
            
        }
        [DataAttribute("FadeLength", typeof(IntPropertyHandler), "FadeInDefaultFadeLength")]
        public string FadeLength
        {
            get
            {
                return fade.Duration.TimeSpan.Seconds.ToString(CultureInfo.InvariantCulture);
            }
            set
            {
                fade.Duration = new TimeSpan(0, 0, 0, Convert.ToInt32(value, CultureInfo.InvariantCulture), 0);
            }
        }
        [DataAttribute("BeginTime", typeof( IntPropertyHandler),"FadeInDefaultBeginTime")]
        public string BeginTime
        {
            get
            {
                return fade.BeginTime.Value.Seconds.ToString(CultureInfo.InvariantCulture);
            }
            set
            {
                fade.BeginTime = new TimeSpan(0, 0, 0, Convert.ToInt32(value, CultureInfo.InvariantCulture), 0);
            }
        }
        [DataAttribute("FadeTo", typeof(DoublePropertyHandler), "FadeInDefaultFadeTo")]
        public string FadeTo
        {
            get
            {
                return fade.To.ToString();
            }
            set
            {
                fade.To = Convert.ToDouble(value, CultureInfo.InvariantCulture);
            }
        }
        public override void Go()
        {
            base.Go();


            ((DiffuseMaterial)CurrentLyricTextPane.Material).Brush.BeginAnimation(Brush.OpacityProperty, fade);  
            //CurrentLyricTextBlock.BeginAnimation(TextBlock.OpacityProperty,fade);
            
        }
    }
   
}
